package com.zl.registration.exception;

import com.zl.registration.module.result.CodeMsg;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author zoulei
 * @date 2021/11/18 17:05
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class BusinessException extends RuntimeException{
    /**
     * 状态码
     */
    private final int code;

    /**
     * 信息
     */
    private final String message;

    /**
     * 详细描述
     */
    private String description;

    public BusinessException(int code, String message, String description) {
        this(code, message);
        this.description = description;
    }

    public BusinessException(CodeMsg codeMsg) {
        super(codeMsg.getMsg());
        this.code = codeMsg.getCode();
        this.message = codeMsg.getMsg();
        this.description = "";
    }

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
        this.message = message;
        this.description = "";
    }

    public BusinessException(String errorMessage) {
        this(-1, errorMessage);
    }
}
